package com.bsoft.gol.hcs.utils;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

import java.util.Iterator;

public class Dom4jUtil {
    public static String readStringXml(String xml) {
        try {
            Document doc = DocumentHelper.parseText(xml);

            Element rootElt = doc.getRootElement();

            Iterator iter = rootElt.elementIterator("Body");
            while (iter.hasNext()) {
                Element recordEle = (Element) iter.next();

                Iterator iters = recordEle.elementIterator("nf_hai_funmainResponse");
                if (iters.hasNext()) {
                    Element itemEle = (Element) iters.next();


                    return itemEle.elementTextTrim("nf_hai_funmainResult");
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
